#include <iostream>
#include <vector>
#include <algorithm> 

namespace CommandSystem
{
    struct Command
    {
        friend struct CommandManager;
        
        virtual bool execute(int argc, char* argv[]) = 0; 
        void operator () (Command* c) {
            _is_pushed = true;
        }

        Command(const char* c) 
            : _command(const_cast<char*>(c)),
              _is_pushed(false) {} 
        ~Command() { delete _command; }
    protected:
        char* _command;
        bool _is_pushed;
    };

    typedef std::vector<Command*> CommandVector;

    struct CommandManager
    {
        void push(Command* cmd) {
            _commands.push_back(cmd);
            cmd->_is_pushed = true;
        }

        CommandManager(std::vector<Command*> cmds) : _commands(cmds) {
            std::for_each(_commands.begin(), _commands.end(), processPushs());
        }

    protected:
        struct processPushs
        {
            void operator ()(Command* c) {
                c->_is_pushed = true;
            }
        };

        CommandVector _commands;
    };
}

int main()
{
    static struct _MyCommand : public CommandSystem::Command
    {
        bool execute(int argc, char* argv[]) {
            std::cout << _command << std::endl;
            return true;
        }

        _MyCommand(const char* c) : CommandSystem::Command(c) {};
    } MyCommand("event log start");

    CommandSystem::CommandVector cv;
    cv.push_back(&MyCommand);

    CommandSystem::CommandManager cm(cv);
    return 0;
}
